<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "{{%model}}".
 *
 * @property integer $id
 * @property string $name
 */
class Model extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%model}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['name'], 'string', 'max' => 45]
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => '属性模型id',
            'name' => '模型名称',
        ];
    }

    /**
     * 一对多属性
     * @return \yii\db\ActiveQuery
     */
    public function getAttr()
    {
        return $this->hasMany(Attribute::className(), ['model_id' => 'id']);
    }
}
